
/**
* 使用窗体或win直接打开url
* @param url
* @param isDialog
* @param width
* @param height
* @param itemName
*/
function openUrl(jsonParam){
	if(jsonParam.isDialog == '1'){
		//居中显示
		var iframeWidth = $(this).width();
		var iframeHeight = $(this).height();
		var setWidth = (iframeWidth - jsonParam.width) / 2;
		var setHeight = (iframeHeight - jsonParam.height) / 2;
		$.iframe.win({
			url:jsonParam.url,
			title:jsonParam.title,
			width:jsonParam.width,
			height:jsonParam.height,
			modal:true,
			maximizable:true,
			minimizable:false,
			resizable:true,
			left:jsonParam.setWidth,
			top:jsonParam.setHeight,
			parameter1_iframedialog:jsonParam.parameter1_iframedialog,
			parameter2_iframedialog:jsonParam.parameter2_iframedialog,
			parameter3_iframedialog:jsonParam.parameter3_iframedialog,
			buttons:jsonParam.buttons,
			style:jsonParam.dialog_style
		});
	}else{
		window.parent.OpenNoProjectPath(jsonParam);
	}
}

/**
 * 向iframe dialog添加buttons
 * @param buttons
 */
function addButtons2IframeDialog(buttons){
	$.iframe.buttons(buttons);
}


/**
 * 关闭事件，供iframe中页面调用
 */
function closeDialog(){
	$.iframe.close();
}


/**
 * 验证是否有权限访问请求的URL
 * @param requestUrl
 * @param callback
 */
function authRequestUrl(requestUrl,callback){
	//alert(requestUrl);
	var authResult = false;
	$.ajax({
		type:"POST",
		url:_path+'/admin123/template/templateAjax_authorizeUsingUrlCheck_access.action',
		dataType:"json",
		data:{url:requestUrl},
		success:function(msg){
			if(JSON.stringify(msg).indexOf('error:')==0){
				callback(authResult);
				window.parent.error(JSON.stringify(msg));
			}else{
				var msgjson = JSON.parse(msg);
				authResult = msgjson.result;
				callback(authResult);
				return;
			}
		},
		error:function(er){
			//alert(22);
			callback(authResult);
			//异步问题，when datagrid load success,then invoke auth,at the same time,close tab,then error,alert is not a good idea.
			//window.parent.error(JSON.stringify(er));
		}
	});
}

/**
 easyui number placeholder
 */
function inputPlaceholder(){
	$(".easyui-numberbox").each(function(i){
		var span = $(this).siblings("span")[0];
		var targetInput = $(span).find("input:first");
		if(targetInput){
			$(targetInput).attr("placeholder", $(this).attr("placeholder"));
		}

	});
	$(".easyui-textbox").each(function(i){
		var span = $(this).siblings("span")[0];
		var targetInput = $(span).find("input:first");
		if(targetInput){
			$(targetInput).attr("placeholder", $(this).attr("placeholder"));
		}

	});
}


function messager_show(msg, timeout){
	$.messager.show({
		title:'消息框',
		msg:msg,
		timeout:timeout,
		showType:'slide'
	});
}


//waiting for test
function currentDate(){
	var d = new Date();
	var year = d.getFullYear()
	var month = d.getMonth()+1;
	if(month<10)month="0"+month;
	var day = d.getDate()
	if(day<10)day="0"+day;
	var dateStr = year+"-"+month+"-"+day;
	return dateStr;
}